package yingyong;

public class demo4 {
    public static void main(String[] args) {
//        int[] arr = {1, 2, 3, 5, 4};
//        try{
//            System.out.println(arr[10]);
//        }
//        catch (ArrayIndexOutOfBoundsException a){
//            a.printStackTrace();
//            //System.out.println("ArrayIndexOutOfBoundsException");
//        }
        int[] b = null;
        int max = 0;
        try {
            max = getmax(b);
        } catch (NullPointerException e) {
            System.out.println("point is null");
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("array index is limit");
        }


        System.out.println(max);
    }

    public static int getmax(int[] b) throws NullPointerException, ArrayIndexOutOfBoundsException{

        if(b==null){
            throw new NullPointerException("point is null");
        }

        if(b.length==0){
            throw new ArrayIndexOutOfBoundsException("array index is limit");
        }

        int max = 0;
        for(int i=0;i<b.length;i++){
            if(max<b[i]){
                max = b[i];
            }
        }

        return max;
    }
}
